/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.sql.ResultSet;
import java.util.ArrayList;
import model.pojo.CTDeal;
import model.util.connect;

/**
 *
 * @author ChiTuan
 */
public class SanPhamChiTietDAO {
    public static CTDeal laysanpham(int idsp){
        
        CTDeal ctd=new CTDeal();
        try{

            String sql=String.format("Select * From Deal Where Id=%d",idsp );
            connect cn=new connect();
            cn.Open();   
            ResultSet rs=cn.executeQuery(sql);
            while(rs.next()){
                
                ctd.setIdDeal(rs.getInt("Id"));
                ctd.setTenDeal(rs.getString("TenDeal"));
                ctd.setGiaGoc(rs.getBigDecimal("GiaGoc"));
                ctd.setGiaGiam(rs.getBigDecimal("GiaGiam"));
                ctd.setPhanTramGiam(rs.getFloat("PhanTramGiam"));
                ctd.setSoPhieuToiThieu(rs.getInt("SoPhieuToiThieu"));
                ctd.setSoPhieuToiDa(rs.getInt("SoPhieuToiDa"));
                ctd.setSoPhieuDaBan(rs.getInt("SoPhieuDaBan"));
                ctd.setSoPhieuConLai(rs.getInt("SoPhieuConLai"));
                ctd.setThoiGianBatDau(rs.getDate("ThoiGianBatDau"));
                ctd.setThoiGianKetThuc(rs.getDate("ThoiGianKetThuc"));
                ctd.setIdCongTy(rs.getInt("IdCongTy"));
                ctd.setIdTinhThanh(rs.getInt("IdTinhThanh"));
                ctd.setSoNguoiMua(rs.getInt("SoNguoiMua"));
                ctd.setMota(rs.getString("Mota"));
                ctd.setSoBinhChon(rs.getInt("BinhChon"));
                ctd.setSoQuangCao(rs.getInt("LuotQuangCao"));
                ctd.setHinhAnh(rs.getString("HinhAnh"));
                
            }
        }
        catch(Exception ex)
        {
            System.out.println(ex);
        }
        return ctd;
    }
}
